package march.test_3_8;

import java.util.*;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int[][] arr = new int[m][n];
        for(int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        int[][] dp = new int[m + 1][n + 1];
        for(int i = 2; i < m + 1; i++) {
            dp[i][0] = -1;
        }
        for(int i = 2; i < n + 1; i++) {
            dp[0][i] = -1;
        }
        Map<Integer,List<int[]>> map = new HashMap<>();
        List<int[]> list = new ArrayList<>();
        for(int i = 1; i < m + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                if(arr[i-1][j -1] == 1) {
                    dp[i][j] = -1;
                } else if(dp[i - 1][j] != -1 && dp[i][j - 1] == -1) {
                    dp[i][j] = dp[i - 1][j] + 1;
                    int[] tmp = {i - 1, j - 1};
                    list.add(tmp);
                    map.put(dp[i][j],list);
                } else if (dp[i - 1][j] == -1 && dp[i][j - 1] != -1) {
                    dp[i][j] = dp[i][j - 1] + 1;
                    int[] tmp = {i - 1, j - 1};
                    list.add(tmp);
                } else if(dp[i - 1][j] != -1 && dp[i][j - 1] != -1) {
                    if(dp[i -1][j] > dp[i][j - 1]) {
                        dp[i][j] = dp[i][j - 1] + 1;
                        int[] tmp = {i -1 , j - 1};
                        list.add(tmp);
                    } else {
                        dp[i][j] = dp[i - 1][j] + 1;
                        int[] tmp = {i - 1, j -1};
                        list.add(tmp);
                    }
                } else {
                    dp[i][j] = -1;
                }
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println("(" + list.get(i)[0] + "," + list.get(i)[1] + ")");
        }
    }
}
